package com.example.definedview;

import androidx.appcompat.app.AppCompatActivity;
import androidx.databinding.DataBindingUtil;

import android.os.Bundle;
import android.view.View;

import com.example.definedview.databinding.ActivityTimeBinding;

import java.util.Calendar;

public class TimeActivity extends AppCompatActivity {
    ActivityTimeBinding activityTimeBinding;
    int tarHours, tarMinutes, tarSeconds;//目标时分秒
    int time;

    //倒计时
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        //setContentView(R.layout.activity_time);
        activityTimeBinding = DataBindingUtil.setContentView(this, R.layout.activity_time);

        activityTimeBinding.set.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {


                time = Integer.valueOf(activityTimeBinding.time.getText().toString());

                activityTimeBinding.clockView.antiClockwise(time);
            }
        });

        activityTimeBinding.start.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
//                Calendar calendar = Calendar.getInstance();
//                tarHours = calendar.get(Calendar.HOUR);
//                tarMinutes = calendar.get(Calendar.MINUTE);
//                tarSeconds = calendar.get(Calendar.SECOND);
//                tarSeconds += time;
//                if(tarSeconds >= 60){
//                    tarSeconds = tarSeconds % 60;
//                    tarMinutes += tarSeconds / 60;
//                }
//
//                if(tarMinutes >= 60){
//                    tarMinutes = tarMinutes % 60;
//                    tarHours = tarMinutes / 60;
//                }
//
//                if(tarHours >= 24){
//                    tarHours = tarHours % 24;
//                }
//                activityTimeBinding.clockView.setTarHours(tarHours);
//                activityTimeBinding.clockView.setTarMinutes(tarMinutes);
//                activityTimeBinding.clockView.setTarSeconds(tarSeconds);
                activityTimeBinding.clockView.startClock(time);
            }
        });
    }
}
